cc.Class({
    extends: cc.Component,

    properties: {
        blocker :
        {
            type : cc.Node,
            default : null,
        },

        msgBoxNode : cc.Prefab,
        msgBoxNode2 : cc.Prefab
    },
    onLoad: function () {
        if( !cc.utils.poper )
        {
            cc.utils.poper = this;
        }

        this.blockerRef = 0;
        this.blockLabels = [];
        this.blocker.active = false;
    },

    popMsgBox : function( text, handle, title )
    {
        cc.log(text);
        var node = cc.instantiate( this.msgBoxNode );
        node.info = {
            text : text,
            title : title || "消息"
        };
        this.popNode( node, handle );
        cc.utils.soundMgr.playSound( "msgbox" );
        return node;
    },

    popMsgBox2 : function( text, handle )
    {
        var node = cc.instantiate( this.msgBoxNode2 );
        node.info = text;
        
        this.popNode( node, handle );
        cc.utils.soundMgr.playSound( "msgbox" );
        return node;
    },
    popNode : function( node, handle )
    {
        handle = handle || "scene";
        switch( handle )
        {
            case "scene":
                var scene = cc.director.getScene().getChildByName( "Canvas" );
                scene.addChild( node );
                break;
            case "persist" :
                this.node.addChild( node );
                break;
        }
    },
    showBlocker : function( )
    {
        this.blockerRef++;
        if( this.blockerRef >= 0 )
        {
            this.blocker.active = true;
        }
    },
    hideBlocker : function()
    {
        this.blockerRef--;
        if( this.blockerRef <= 0 )
        {
            this.blocker.active = false;
        }
    },
});